package com.zhengsr.wanandroid.ui.main.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zhengsr.corelib.bean.KnowTreeBean;
import com.zhengsr.corelib.utils.CommonUtils;
import com.zhengsr.wanandroid.R;

import java.util.List;

/**
 * Created by zhengshaorui
 * Time on 2019/2/25
 */

public class KnowTreeAdapter extends BaseQuickAdapter<KnowTreeBean,BaseViewHolder> {


    public KnowTreeAdapter(int layoutResId, @Nullable List<KnowTreeBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, KnowTreeBean item) {
        if(item.getName() == null) {
            return;
        }
        helper.setText(R.id.item_knowledge_hierarchy_title, item.getName());
        helper.setTextColor(R.id.item_knowledge_hierarchy_title, CommonUtils.randomColor());
        if (item.getChildren() == null) {
            return;
        }
        StringBuilder content = new StringBuilder();
        for (KnowTreeBean data: item.getChildren()) {
            content.append(data.getName()).append("   ");
        }
        helper.setText(R.id.item_knowledge_hierarchy_content, content.toString());
    }
}
